package itxx.itxx;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletDemo2 extends HttpServlet{
    //创建并声明对象
    @Override
    public void init() throws ServletException {
        System.out.println("对象创建并初始化成功...对象只会创建一次");
    }

    //对象服务
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doget方法执行了");
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        this.doGet(req, resp);
        System.out.println("dopost方法执行了");
    }



    //对象销毁过程
    @Override
    public void destroy() {
        System.out.println("只有结束tomcat服务,才会将对象销毁");
    }
}
